package com.gome.ocean.service.utils;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import com.gome.ocean.dao.model.gddl.ClusterBO;
import com.gome.ocean.dao.model.gddl.ConnectionStatusVO;



public class ListSortUtil {

    public static void sortClusterByName(List<ClusterBO> list) {
        Collections.sort(list, new Comparator<ClusterBO>() {

            @Override
            public int compare(ClusterBO c1, ClusterBO c2) {
                return (c1).getName().compareTo((c2).getName());
            }
        });
    }

    public static void sortCobarByName(List<ClusterBO> list) {
        Collections.sort(list, new Comparator<ClusterBO>() {

            @Override
            public int compare(ClusterBO o1, ClusterBO o2) {
                return o1.getName().compareTo(o2.getName());
            }

        });
    }


    public static void sortConnections(List<ConnectionStatusVO> list) {
        Collections.sort(list, new Comparator<ConnectionStatusVO>() {

            @Override
            public int compare(ConnectionStatusVO o1, ConnectionStatusVO o2) {
                if (o1.getHost().equals(o2.getHost())) {
                    return (int) (o2.getNetOut() - o1.getNetOut());
                }
                return o1.getHost().compareTo(o2.getHost());
            }

        });
    }
}
